'''
快捷添加用户类页面
'''
from selenium.webdriver.common.by import By
from page.base_page import BasePage
from selenium.webdriver.support.select import Select

class AddUserYouxiangPage(BasePage):

    # 定位器
    youxiangyaoqing_btn_locator = (By.LINK_TEXT, '邮箱邀请')

    tianjiayonghu_yonghuming_locator = (By.ID, 'name')
    tianjiayonghu_youxiang_locator = (By.ID, 'email')
    tianjiayonghu_yonghuleibie_locator = (By.NAME, 'category_id')
    tianjiayonghu_bumen_locator = (By.ID, 'department')
    tianjiayonghu_gangwei_locator = (By.ID, 'role')

    tianjiayonghu_tianjia_btn_locator = (
    By.XPATH, '/html/body/div[5]/div[2]/div/div/div[1]/form/table/tbody/tr[6]/td[2]/input[1]')
    tianjiayonghu_baocunxinjian_btn_locator = (By.CSS_SELECTOR, '[value="保存并新建"]')

    tjyh_duanyan_youxiangweikong_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/div[1]')

    # 进入邮箱添加
    def tjyh_yx_into(self):
        self.driver.find_element(*self.youxiangyaoqing_btn_locator).click()

    # 输入用户名
    def tjyh_yx_yhm(self, name):
        self.driver.find_element(*self.tianjiayonghu_yonghuming_locator).send_keys(name)

    # 输入邮箱
    def tjyh_kj_yx(self, youxiang):
        self.driver.find_element(*self.tianjiayonghu_youxiang_locator).send_keys(youxiang)

    # 选择用户类别
    def tjyh_kj_yhlb(self):
        yhlb = self.driver.find_element(*self.tianjiayonghu_yonghuleibie_locator)
        Select(yhlb).select_by_index(1)

    # 选择部门
    def tjyh_kj_bm(self):
        bumen = self.driver.find_element(*self.tianjiayonghu_bumen_locator)
        Select(bumen).select_by_index(1)

    # 选择岗位
    def tjyh_kj_gw(self):
        gangwei = self.driver.find_element(*self.tianjiayonghu_gangwei_locator)
        Select(gangwei).select_by_index(0)

        # 点击保存
    def tjyh_kj_baocun(self):
        self.driver.find_element(*self.tianjiayonghu_tianjia_btn_locator).click()

        # 点击保存并新建
    def tjyh_kj_baocunbingxinjian(self):
        self.driver.find_element(*self.tianjiayonghu_baocunxinjian_btn_locator).click()

    # 断言地址
    def get_current_url(self):
        return self.driver.current_url

    # 断言密码为空
    def tjyh_dy_youxiangweikong(self):
        wb=self.driver.find_element(*self.tjyh_duanyan_youxiangweikong_locator)
        return wb.text